package com.john.excel.create;

import org.apache.poi.ss.usermodel.CellStyle;

/**
 * 创建xlsx列控制属性
 * @author john
 */
public class SelectCellAttr{
	//通用属性
	private short  border = CellStyle.BORDER_THIN;	//边框
	private String borderColor = "C6C6C6";	//边框颜色
	private String backgroundColor = "ffffff";	//背景颜色
	private String fontColor = "000000";	//字体颜色
	private short verticalAlignment = CellStyle.VERTICAL_CENTER;	//对齐方式	垂直
	private short alignment = CellStyle.ALIGN_CENTER;	//对齐方式	水平
	private boolean wrapText = true;	//是否自动换行
	private Integer cellWith = 20;	//列宽
	private short rowHeight = 2;	//行高
	private String vlaue;
	private PromptBox promptType;	//效验类型
	
	private String name;	//下拉数组名字
	private Integer cellIndex;	//应用列
	private Integer level = 0;	//级别 一级或非级联默认0,二级1 三级2 ....级别最高12持级级联下拉
	private String data[];	//下拉数据
	private boolean cascade;	//是否级联
	
	public String getName() {
		return name;
	}

	public Integer getCellIndex() {
		return cellIndex;
	}

	public String[] getData() {
		return data;
	}

	public boolean isCascade() {
		return cascade;
	}

	public Integer getLevel() {
		return level;
	}

	/**
	 * CellAttr xlsx属性 请按照下拉框顺序添加数据
	 * @param name	下拉列表名称 不能重复
	 * @param cellIndex	列下标 1开始
	 * @param level 下拉级联时，父级的位置 从1开始   如果给1，表示从A列开始，2，就是从B列
	 * @param data 下拉数据
	 * @param cascade 是否级联
	 * @return
	 */
	public SelectCellAttr setSelectCellAttr(String name,Integer cellIndex,Integer level,String data[],boolean cascade){
		this.name = name;
		this.cellIndex = cellIndex;
		this.data = data;
		this.cascade = cascade;
		this.level = (level <= 0 ? 1 : level);
		return this;
	}
	
	/**
	 * 获取列宽 默认(20 * 256)
	 * @return
	 */
	public Integer getCellWith() {
		return cellWith * 256;
	}
	
	/**
	 * 获取行高 默认 (2 * 180)
	 * @return
	 */
	public short getRowHeight() {
		return (short) (rowHeight * 180);
	}
	
	/**
	 * 获取是否自动换行 默认true
	 * @return
	 */
	public boolean getWrapText() {
		return wrapText;
	}
	
	/**
	 * 获取背景颜色 默认ffffff
	 * @return
	 */
	public String getbackgroundColor() {
		return backgroundColor;
	}
	
	/**
	 * 获取单元格数值 无默认值
	 * @return
	 */
	public String getVlaue() {
		return vlaue;
	}
	
	/**
	 * 获取对齐方式 默认CellStyle.VERTICAL_CENTER 垂直
	 * @return
	 */
	public short getVerticalAlignment() {
		return verticalAlignment;
	}
	
	/**
	 * 获取对齐方式 默认CellStyle.ALIGN_CENTER 水平
	 * @return
	 */
	public short getAlignment() {
		return alignment;
	}
	
	/**
	 * 获取边框 CellStyle.BORDER_THIN
	 * @return
	 */
	public short getBorder() {
		return border;
	}
	
	/**
	 * 获取边框颜色 默认C6C6C6
	 * @return
	 */
	public String getBorderColor() {
		return borderColor;
	}
	
	/**
	 * 获取字体颜色 默认000000
	 * @return
	 */
	public String getFontColor() {
		return fontColor;
	}
	
	/**
	 * 设置边框 默认CellStyle.BORDER_THIN
	 * @param rowHeight
	 * @return
	 */
	public SelectCellAttr setBorder(short  border) {
		this.border = border;
		return this;
	}
	
	/**
	 * 设置行高 默认(2 * 180)
	 * @param rowHeight
	 * @return
	 */
	public SelectCellAttr setRowHeight(Integer rowHeight) {
		this.rowHeight = Short.valueOf(rowHeight.toString());
		return this;
	}
	
	/**
	 * 设置列宽 默认 (20 * 256)
	 * @param cellWith
	 * @return
	 */
	public SelectCellAttr setCellWith(Integer cellWith) {
		this.cellWith = cellWith;
		return this;
	}
	
	/**
	 * 是否自动换行 默认true
	 * @param wrapText
	 * @return
	 */
	public SelectCellAttr setWrapText(boolean wrapText) {
		this.wrapText = wrapText;
		return this;
	}
	
	/**
	 * 设置对齐方式 默认CellStyle.VERTICAL_CENTER 垂直
	 * @param verticalAlignment
	 * @return
	 */
	public SelectCellAttr setVerticalAlignment(short verticalAlignment) {
		this.verticalAlignment = verticalAlignment;
		return this;
	}
	
	/**
	 * 设置对齐方式 默认CellStyle.ALIGN_CENTER 水平
	 * @param alignment
	 * @return
	 */
	public SelectCellAttr setAlignment(short alignment) {
		this.alignment = alignment;
		return this;
	}
	
	/**
	 * 设置字体颜色 默认000000
	 * @param fontColor
	 * @return
	 */
	public SelectCellAttr setFontColor(String fontColor) {
		if(fontColor != null && !fontColor.equals("")){
			this.fontColor = fontColor;
		}
		return this;
	}
	/**
	 * 设置边框颜色 默认C6C6C6
	 * @param borderColor
	 * @return
	 */
	public SelectCellAttr setBorderColor(String borderColor) {
		if(borderColor != null && !borderColor.equals("")){
			this.borderColor = borderColor;
		}
		return this;
	}
	
	/**
	 * 设置背景颜色  默认ffffff
	 * @param backgroundColor
	 * @return
	 */
	public SelectCellAttr setBackgroundColor(String backgroundColor) {
		if(backgroundColor != null && !backgroundColor.equals("")){
			this.backgroundColor = backgroundColor;
		}
		return this;
	}
	
	/**
	 * 设置单元格数值 默认空
	 * @param vlaue
	 * @return
	 */
	public SelectCellAttr setVlaue(String vlaue) {
		if(vlaue != null && !vlaue.equals("")){
			this.vlaue = vlaue;
		}
		return this;
	}
	/**
	 * 获取提示类型
	 * @return
	 */
	public PromptBox getPromptType() {
		return promptType;
	}
	
	/**
	 * 设置提示类型
	 * @param promptType
	 * @return
	 */
	public SelectCellAttr setPromptType(PromptBox promptType) {
		this.promptType = promptType;
		return this;
	}
	
	/**
	 * 设置文本提示信息
	 * @param promptType
	 * @return
	 */
	public SelectCellAttr setPromptType(String promptValue) {
		PromptBox box = new PromptBox(promptValue," ");
		this.promptType = box;
		return this;
	}
	
}
